English
Configure router DNS
Each router is different, so you might need to read the manual on how to do specific steps. The guide will use an OpenWrt router as an example since it's open source nature aligns with the spirit of this guide.
We will configure our upstream DNS and use DNS-over-HTTPS (DoH) for better privacy; we will configure DHCP IP ranges; we will set a static IP for the server; we will configure the DNS to add the devices with static IP to the lan domain; and finally, configure the Split Horizon for our DuckDNS.org subdomain, so it can work inside our LAN.
Steps
- Access to your router's portal, for example through https://192.168.1.254. Use your router's IP.
- Log in with your router's credentials.
- Configure upstream DNS.
- Navigate to "System" > "Software".
- Click
Update lists...button. - Under
Download and install packageinputluci-app-https-dns-proxy. ClickOK. - Navigate to "Services" > "HTTPS DNS Proxy". If you don't see it, try rebooting your router.
- The plugin comes with Cloudflare and Google DNS preconfigured. Remove Google DNS from the bottom list or choose your provider here.
- At the top, make sure that the service is enabled and started. You should see the
StartandEnablebuttons disabled. If not, click on them. - Click the
Save & Applybutton.
- Configure Adblock.
- Navigate to "System" > "Software".
- Click
Update lists...button. - Under
Download and install packageinputluci-app-adblock. ClickOK. - Navigate to "Services" > "Adblock". If you don't see it, try rebooting your router.
- Navigate to "Blocklist Sources" tab.
- In
Sources, select the block lists that you prefer. - Click the
Save & Applybutton.
- Configure DHCP range.
- Navigate to "Network" > "Interfaces".
- Edit the
laninterface. - Navigate to "DHCP Server" tab.
- Set
Startto64andLimitto189. - Click the
Savebutton. - Click the
Save & Applybutton.
- Set static IP for server.
- Look for the name of the active physical network device, for example
enp1s0oreth0:nmcli device status. If there is more than one physical device, select the one that is connected to the router with the best speed. Replaceenp1s0in the following commands with the correct device. - Assign static IP and CIDR range:
nmcli con mod enp1s0 ipv4.addresses 192.168.1.253/24. Typically home routers use a CIDR range of/24or its equivalent subnet mask255.255.255.0. Check your router's manual for more information. - Disable DHCP client:
nmcli con mod enp1s0 ipv4.method manual. - Configure the router IP:
nmcli con mod enp1s0 ipv4.gateway 192.168.1.254. Normally the router assigns itself a static IP which is the second to last IP in the IP range. - Configure the router as DNS and Cloudflare as fallback DNS:
nmcli con mod enp1s0 ipv4.dns "192.168.1.254 1.1.1.1". If you like to use another DNS like Google's, you can change it. - Reactivate the device for the changes to take effect:
nmcli con up enp1s0. This may terminate the SSH session. if so,sshto the server again.
- Look for the name of the active physical network device, for example
- Set static IPv6 for server (Optional). Only if your router is using IPv6.
- Navigate to "Network" > "DHCP" > "Leases".
- Click the
Addbutton. Hostname:server.MAC Addresses: select the MAC Address of the server from the list.IPv4:192.168.1.253.DUID/IAIDs: select the DUID for the server. Make sure the IAID is the one for the main network device and not for the macvlan shim we created before.IPv6 Token:fffd.- Click the
Savebutton. - Navigate to "Network" > "Interfaces" > "Global network options".
- Make sure there is a ULA Prefix set and write it down. if not, you can generate a new one with https://simpledns.plus/private-ipv6 like before.
- If you have more than one lan interface (like a guest or iot interface), make sure you set the IPv6 assignment hint to
1for thelaninterface. - Click the
Save & Applybutton. Your server should now have an IPv6 address that starts with that ULA prefix and ends withfffd. If not, make sure yourlaninterface is allowing ULA in the prefix filter or try resetting the server network to ask for a new IPv6 address.
- Add services with static IP to the
landomain. Since they don't use DHCP, the router won't add them to the hosts list. We have not created Home Assistant service yet, but it will have its IP ready.- Navigate to "Network" > "DHCP and DNS" > "Hostnames".
- Click the
Addbutton. Hostname:homeassistant.IP Address:192.168.1.11.- Click the
Savebutton. - Click the
Save & Applybutton.
- Add Split Horizon DNS for our subdomain.
- Navigate to "General" tab.
Addresses:/.myhome.duckdns.org/192.168.1.253&/.myhome.duckdns.org/XXXX::fffdwhere XXXX::fffd is the ULA IPv6 of the server. You can see this address in the "Leases" tab under "Active DHCPv6 Leases". If you don't have IPv6, just use the IPv4 line.- Click the
Save & Applybutton.